package com.party.wechat;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.party.dto.Response;

/**
 * 
 * @author Caizhf
 * @date 2017年8月18日上午2:03:59
 * @version v.0.1
 * @email 1115054416@qq.com 
 *
 * <p>Description: 微信二维码图片增加与更新操作</p>
 *
 */
@RestController
@RequestMapping("/wechat")
public class ImageController {
	@Autowired
	private WechatImageMapper mapper;
	
	private static final Logger logger = LoggerFactory.getLogger(ImageController.class);
	
	@Value("${image.tomcat.uri}")
	private String imageUri;
	
	
	//显示图片
	@RequestMapping("/get")
	public Response get(HttpServletRequest req){
		WeChatImg img = mapper.find();
		String reqUrl = req.getRequestURL().toString();
		String reqUri = req.getRequestURI();
		String showUrl = reqUrl.replaceAll(reqUri, imageUri+img.getImgName());
		return Response.success(showUrl);
	}
	
}
